from django.utils.deprecation import MiddlewareMixin


class SameSiteMiddleware(MiddlewareMixin):

    def process_request(self, request):
        setattr(request, '_dont_enforce_csrf_checks', True)
    def process_response(self, request, response):
        if 'sessionid' in response.cookies:
                response.cookies['sessionid']['samesite'] = 'None'
        if 'csrftoken' in response.cookies:
                response.cookies['csrftoken']['samesite'] = 'None'
        return response